/**
 * tpshion-cloud-base
 * 基础设施服务接口
 */
import axios from '@/libs/http'
import qs from 'qs'

/**
 * 获取在线服务
 */
export const getAllService = () => {
  return axios({
    method: 'get',
    url: '/base/discovery'
  })
}

/**
 * 获取访问次数
 */
export const getRequstNum = () => {
  return axios({
    method: 'get',
    url: '/base/reqNum'
  })
}

/**
 * 获取实例服务列表(未分页，需要前端分页)
 */
export const getService = data => {
  console.log('dad',data)
  let param = {pageNum: data.pageNum, pageSize: data.pageSize, serviceName: data.serviceName}
  return axios({
    method: 'post',
    url: '/base/services',
    data: qs.stringify(param)
  })
}

/**
 * 获取配置信息
 */
export const getConfigInfo = data =>{
  return axios({
    method: 'post',
    url: '/base/configs',
    data: data
  })
}

/**
 * 保存修改配置
 */
export const updateConfig = data => {
  return axios({
    method: 'post',
    url: '/base/config?action=upd',
    data: data
  })
}

/**
 * 接口请求信息
 */
export const requestInfo = serviceName => {
  return axios({
    method: 'get',
    url: '/base/trace?serviceName='+serviceName
  })
}

/**
 * 获取jvm信息
 */
export const jvmInfo = serviceName => {
  return axios({
    method: 'get',
    url: '/base/jvm?serviceName='+serviceName
  })
}

/**
 * 获取服务组件状态
 */
export const componentInfo = serviceName => {
  return axios({
    method: 'get',
    url: '/base/components?serviceName='+serviceName
  })
}

/**
 * 获取服务日志信息
 */
export const logInfo = serviceName => {
  return axios({
    method: 'get',
    url: '/base/logfile?serviceName='+serviceName
  })
}
